package com.hc.pingtan.service.impl;

import cn.hutool.core.util.RandomUtil;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hc.pingtan.mapper.KekeWitkeyMemberMapper;
import com.hc.pingtan.model.KekeWitkeyMember;
import com.hc.pingtan.service.IKekeWitkeyMemberService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author astupidcoder
 * @since 2021-11-09
 */
@Service
@DS("db1")
public class KekeWitkeyMemberServiceImpl extends ServiceImpl<KekeWitkeyMemberMapper, KekeWitkeyMember> implements IKekeWitkeyMemberService {

    @Override
    public void createAccount(String accountName) {
        QueryWrapper<KekeWitkeyMember> queryWrapper = new QueryWrapper();
        queryWrapper.eq("username", accountName);
        List<KekeWitkeyMember> list = this.baseMapper.selectList(queryWrapper);
        if (!list.isEmpty()) {
            return;
        }
        KekeWitkeyMember kekeWitkeyMember = new KekeWitkeyMember();
        kekeWitkeyMember.setUsername(accountName);
        kekeWitkeyMember.setPassword("e10adc3949ba59abbe56e057f20f883e");
        kekeWitkeyMember.setEmail("330315621@qq.com");
        kekeWitkeyMember.setRandCode(RandomUtil.randomString(6));
        this.baseMapper.insert(kekeWitkeyMember);
    }
}
